{% extends 'journal/base.html' %}

{% load editorjs %}

{% block main %}
    <div >
        {% if posts %}
            {% for post in posts %}
                <p >
                    <h2>{{ post.title }}</h2>
                    <p >
                        {% with author_url=post.author.get_absolute_url %}
                            {% if author_url %}
                                <a href="{{ author_url }}" >{{ post.author }}</a>
                            {% else %}
                                <span >{{ post.author }}</span>
                            {% endif %}
                        {% endwith %}
                        {% if post.published_at %}
                            <span >发布于 {{ post.published_at|date:"Y年m月d日" }}</span>
                        {% endif %}
                    </p>
                    <p >
                        {{ post.content|editorjs|striptags|truncatechars:150 }}
                    </p>
                    <a href="{% url 'post_detail' post.id %}" >
                        阅读更多
                    </a>
                </p>
            {% endfor %}
        {% else %}
            <p>暂无日志</p>
        {% endif %}
    </div>
{% endblock %}